package com.chuangxin.data.core;

import com.chuangxin.data.core.io.DataOutput;

/**
 * Created by Dawnwords on 2015/2/1.
 */
public abstract class URLContentIndependentFetcher extends WebPageFetcher {

    public URLContentIndependentFetcher(DataOutput output) {
        super(output);
    }

    public URLContentIndependentFetcher(int threadNum, DataOutput output) {
        super(threadNum, output);
    }

    @Override
    public void execute() {
        super.execute();
        new URLGenerator().start();
    }

    protected abstract String nextURL();

    protected abstract boolean hasNextURL();

    private class URLGenerator extends Thread {
        @Override
        public void run() {
            while (hasNextURL()) {
                putURL(nextURL());
            }
        }
    }

}



